<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <script>
    //深度优先搜索
    var maxDepth = function (root) {
      // 定义：输入一个节点，返回以该节点为根的二叉树的最大深度
      if (root == null) return 0;
      return 1 + Math.max(maxDepth(root.left), maxDepth(root.right));
    };
    console.log(maxDepth([3, 9, 20, null, null, 15, 7]))

  </script>
</body>

</html>